package com.crazybytex.modbus.service;

import com.serotonin.modbus4j.ModbusMaster;
import com.crazybytex.modbus.beans.BatteryLoadVoltageAndCurrentResponse;
import com.crazybytex.modbus.util.ModbusUtil;

import static com.crazybytex.modbus.Constant.*;

/**
 * @Author 程序员潇然 crazybytex.com
 * @Date 2022/8/4 9:42
 * @Description TODO
 **/
public class BatteryService {

    public BatteryLoadVoltageAndCurrentResponse getLoadVoltageAndCurrent(ModbusMaster client, int slaveId){
        BatteryLoadVoltageAndCurrentResponse batteryLoadVoltageAndCurrentResponse = new BatteryLoadVoltageAndCurrentResponse();
        ModbusUtil.readInputRegisters(client,slaveId,ADDRESS_LOAD_VOLTAGE,2,batteryLoadVoltageAndCurrentResponse);
        return batteryLoadVoltageAndCurrentResponse;
    }

}
